// pages/index/index.js

var api=require("../../utils/api.js");
var sliderWidth=96;

Page({
    data:{
        tabs: ["简约","中式","欧式","美式"],
        activeIndex: 0,
        loupanlist: [], //楼盘列表
        anlilist: [],
        after_service: [],
        stylecases:[[],[],[],[]]
    },
    loadswiper(){
        api.get({
            url: 'home/slider/1',
            success: data=>{
                if(data.code==1){
                    this.setData({
                        movies: data.data[0].items
                    })
                }
            }
        });
    },

    onload: function(options){
        this.loadswiper();
        //this.loadloupan();
        //this.loaccases();
        //this.loadfuwu();
        //this.loadafterservice();
        this.dialog=this.selectComponent("#mydialog");
        this.loadcitys()
        //this.this.loadonlineforming();
    },
    tabClick: function(e){
        this.setData({
            activeIndex: e.currentTarget.id
        });
    },

    loadonlineforming(){
        api.get({
            url: 'home/slides/9',
            success: data=>{
                if(data.code==1){
                    this.setData({
                        forming: data.data[0].items
                    })
                }
            }
        });
    },
    loadfuwu(){
        aoi.get({
            url: 'homt/slides/3',
            success: data=>{
                if(data.code==1){
                    this.setData({
                        fuwulist: data.data[0].items
                    })
                }
            }
        });
    },

    loadsfterservice(){
        api.get({
            url: 'home/slides/4',
            success: data=>{
                if(data.code==1){
                    this.setData({
                        after_service: data.data[0].items
                    })
                }
            }
        });
    },

    loadcitys(){
        api.get({
            url: 'home/attribute/11',
            success: data=>{
                if(data.code==1){
                    this.setData({
                        citys: data.data[0].items
                    })
                }
            }
        });
    },

    formSubmit(e){
        //提交表单数据
        console.log(3)
        api.post({
            url: 'portal/diyform/insert',
            data: e.detail.value,
            success:data=>{
                if(data.code=="1"){
                    wx.showToast({title: '报名成功', icon: 'success'})
                }
                if(data.code=="0"){
                    wx.showToast({title: data.msg, icon: 'none'})
                }
            }
        })
    },

    onHide: function(){
        this.dialog.hideModal();
    },
    onUnload: function(){},

    onPullDownRefresh: function(){},
    onReachBottom: function(){},
    onShareAppMessage: function(){}

})